package com.demo.wechat.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/*")
public class AppServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 告诉tomcat容器，响应数据的数据格式与字符编码。否则会乱码。
        response.setContentType("text/html;charset=UTF-8");
        // 构造返回的数据流。下面构建html的文档内容。
        response.getWriter().println("<html>");
        response.getWriter().println("<h1>Hello</h1>");
        response.getWriter().println("<h1>This is AppServlet...</h1>");
        response.getWriter().println("</html>");
        System.out.println(request.getRequestURL());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
